<?php
require_once ("src/db/connectdatabase.php");

function getNews($idtype) {
	$con = new ConnectDB();
	
	$sql = "SELECT new_id, new_title, datecreate, new_tomtat FROM news WHERE idtnew=".$idtype." ORDER BY datecreate DESC LIMIT 0,4";
	return $con -> getvalueString($sql);
}

function getTypeNews() {
	$con = new ConnectDB();
	
	$sql = "SELECT idtnew, nametypenew FROM typenews ORDER BY no";
	return $con -> getvalueString($sql);
}

function int_to_date($int)
{
    $time  = date("d/m/Y", $int);
    return $time;
}

$arrtnew = getTypeNews();

?>
<script type="text/javascript">
    document.title = "Tổng hợp các tin tức tài chính mới nhất tại Việt Nam - Tài Chính Online";

</script>
<style>
.tblwt_txt {
	color: #FFFFFF;
	font-size: 13px;
	font-weight: bold;
	padding: 2px;
}

.tbl_txt {
	color: #373737;
	font-size: 11px;
	padding: 2px;
}

#txt .link-click-xemthem-class {
	color: #666666;
	font-size: 11px;
	line-height: 15px;
	text-decoration: none;
}

#txt .link-click-xemthem-class {
	text-decoration: none;
}

#txt .link-click-xemthem-class:hover {
	color: #8DAE48;
	text-decoration:none;
}

</style>
<div class="text12" style="margin: auto; width: 970px; height: 11px; margin-top: 11px; color: #0a8bd9;">
	<u><a href="<?php echo($host) ?>" class="text12" style="color: #0080d6;">Trang Chủ</a></u>&gt; <a href="#" class="text12" style="color: #4c4c4c;">Tin tức</a></span>
</div>
<div class="intrl_txt" style="margin: auto;">
    <div style="float: left; width: 660px; margin-top: 20px; clear: right;">
    <?php
	foreach($arrtnew as $emain) {
		$arrnews = getNews($emain[0]);
		
		$strbanknameurl = $emain[1];
		$strbanknameurl = rewriteTextUrl(stripUnicode($strbanknameurl));
	?>
        <div id="txt" class="main-show-news">
            <table width="660" border="0" cellpadding="1" cellspacing="1" bgcolor="#d5cfb1">
                <tbody>
                    <tr bgcolor="#8DAE48">
                        <td height="30" align="left"><a class="link-click-xemthem-header-class" href="<?php echo($host) ?>tin-tuc/<?php echo($emain[0]) ?>/<?php echo($strbanknameurl) ?>.html"><b class="tblwt_txt" style="padding-left: 3px; font-size: 14px;"><?php echo($emain[1]) ?></b></a></td>
                    </tr>
                	<?php
					foreach($arrnews as $entry) {
						$strbanknameurl2 = $entry[1];
						$strbanknameurl2 = rewriteTextUrl(stripUnicode($strbanknameurl2));
					?>
                    <tr bgcolor="#EFEEEE">
                        <td align="left" bgcolor="#FFFFFF" class="tbl_txt"><div style="position: relative; margin-bottom: 15px;"><div><div style="height:5px; width: 100%;"></div><strong><a class="link-click-xemthem-class" href="<?php echo($host) ?>tin-tuc/detail/<?php echo($entry[0]) ?>/<?php echo($strbanknameurl2) ?>.html"><?php echo($entry[1]) ?></a></strong> <br /><p><?php echo($entry[3]) ?></p></div><div style="clear:both;"><span style="position: absolute; right: 5px; bottom: -15px;"><?php echo(int_to_date($entry[2])) ?></span></div> </div></td>
                    </tr>
                    <tr></tr>
                    <?php
					}
					?>
                </tbody>
            </table>
        </div>
        <div style="width:660px; background: #CCC; text-align:right;"><a class="link-click-xemthem-class" href="<?php echo($host) ?>tin-tuc/<?php echo($emain[0]) ?>/<?php echo($strbanknameurl) ?>.html" style="color:#167BC7; margin-right: 15px;">Xem Thêm</a></div>
        <div style="clear:both; margin-top: 10px;"></div>
        <?php
	}
		?>
    </div>
	
    <div style="float: right; clear: right; width: 275px; height: auto;background-image: url(<?php echo($host) ?>images/gray_bg.gif);  margin-top: 10px;">
        <?php include("formsendapplyloan.php"); ?>
    </div>
</div>

<style>
	.main-show-news img {
		margin-right: 5px;
	}
</style>